<template>
  <!-- 区域权限管理 -->
  <div class="flUserCommunity">
    <div :class="[{leftClick:jurisdictionStatus},{left:!jurisdictionStatus}]">
      <div class="user">
        <searchComponents :key="searchKey" :searchData="dataModel" @searchCallBack="searchCallBack" :optionsZi="optionsZi" :searchOptionTable="searchOptionTable" :getFindByTypeData="getFindByTypeData"></searchComponents>
        <!-- @clearSearch='clearSearch' -->
        <div style="border-top:1px solid #E6E6E6;margin:0 30px;"></div>
        <div style="padding: 25px 30px;">
          <!-- 右侧公共组件 -->
          <rightButtons style="float:right;padding:10px;margin-top:-10px;margin-bottom:15px;margin-right:-10px;" @sunS_F='sunS_F' @configuration='configuration' @emptySearch='emptySearch'></rightButtons>
        </div>
      </div>
      <div class="out" style="padding:0px 30px">
        <!-- 字典 -->
        <dictionaries :searchData='dataModel' :modelType='modelType' @optionData="dictionariesCallBack"></dictionaries>
        <!--数据列表-->
        <!-- {{dataAttribute}} -->
        <el-table ref="multipleTable" :data="dataAttribute" @selection-change="handleSelectionChange" v-loading.body="false" border fit max-height="511px" highlight-current-row size="mini" :cell-style="{padding:'5px 0'}">
          <el-table-column align="center" type="selection" :show-overflow-tooltip="true" width="45"></el-table-column>
          <el-table-column align="center" label="序号" type="index" :index="indexMethod" width="54px">
          </el-table-column>
          <el-table-column align="center" min-width="140px" v-for="item in dataModel" v-if="item.tableSign" :key="item.id" :label="item.CN" :show-overflow-tooltip="true">
            <template slot-scope="scope">{{item.type === 'select' ? optionDatas(item.typeGroupCode ? optionsZi[item.EN] : searchOptionTable[item.EN],scope.row[item.EN],item.EN):scope.row[item.EN]}}</template>
          </el-table-column>
          <el-table-column width="180px" align="center" label="操作" fixed="right">
            <template slot-scope="scope">
              <!-- 授权按钮 -->
              <el-button style="color:#0B9AC3;border:none;" icon="el-icon-s-check" circle @click="jurisdictionClick(scope.row)"></el-button>
              <!-- @click="makeExaId(scope.row)" -->
            </template>
          </el-table-column>
        </el-table>
        <!-- 分页 -->
        <el-pagination style="margin-top:15px;" @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage" :page-sizes="[10, 20, 30, 40]" :page-size="pagesize" layout="total, sizes, prev, pager, next, jumper" :total="pagetotal"></el-pagination>
      </div>
      <!-- 查看组件 -->
      <examine :DialogVisibleMod="DialogVisibleExamine" :modData="examineData" :attributeOrder="dataModel" @examineDialog="examineDialog" :optionsZi="optionsZi" :searchOptionTable="searchOptionTable" :getFindByTypeData="getFindByTypeData"></examine>
    </div>
    <div v-if="jurisdictionStatus" :class="[{rightClick:jurisdictionStatus},{right:!jurisdictionStatus}]">
      <div class="left" v-loading="left_loading" element-loading-background="rgba(0, 0, 0, 0.8)">
        <div class="one">
          <span class="fontone">
            <span style="color:#999999;">
              <i class="el-icon-caret-right" @click="Conceal_201"></i>
            </span>
            <span>区域权限</span>
            <span class="icon">
              <i class="el-icon-bank-card" @click="menuSave"></i>
            </span>
          </span>
        </div>
        <div class="btns">
          <!-- <button class="childb" @click="clickAllFun">全选</button> -->
          <button class="childb" @click="resetFun">重置</button>
        </div>
        <div>
          <!--  @check="checkChange" 当前小区只能选择一个子节点 -->
          <el-tree ref="tree" @check="checkClick" @check-change='checkChange' check-strictly highlight-current class="tree_out" :data="areaData" show-checkbox node-key="id" :default-expanded-keys="treeNodeArray" :default-checked-keys="treeNodeArray" :props="defaultPropsLeft" :filter-node-method="filterNode" @node-click="NodeClick"></el-tree>
          <!-- setCheckedNodes check-strictly @check="checkClick" @check-change='checkChange' -->
        </div>
      </div>
    </div>

  </div>
</template>
<script>
//引入组件
import {
  SearchCForL,
  buttonhurdle,
  examine,
  searchComponents,
  rightButtons,
  dictionaries,
} from '@/views/components/FLPage'
//引入组件
// import addComponent from "./addComponent";
//引入组件
// import modificationi from "./modificationi";
//引入api ajax
//引入API
import {
  postAddUserAndMember, //增加
  deleteByuserId, //单项删除
  searchPageSize, //分页查询
  putUpdateUserAndMember, //修改
  examineBaseTenantInformation, //查看
  forSABT, //查角色
  //不知道做什么的请求
  getselectAllByType,
  //根据ID获取
  FindByLevel, //查询租户管理员的租户
  FindByUserId, //根据用户id查询用户角色中间表
  SAllByType1, //获得用户
  getSelectByCodeAndType, //用于添加租户管理员时选择租户后之间传回选择租户的角色：
  findByType, //获取租户信息
  returnPass, //重置密码
  // selectNameByuserId//租户管理员编辑组件  查询角色
} from '@/api/admin/user/index'
import {
  selectNameByuserId, //租户管理员编辑组件  查询角色
} from '@/api/TenantAdministratorManagement'
import {
  getTree, //区域树--小区资料全部
  selectByUserId, //默认选中的水表
  flUserCommunitySave, //保存 权限
} from '@/api/baseManage/flCommunity/index'
export default {
  components: {
    // buttonhurdle,
    // modificationi,
    examine,
    searchComponents,
    SearchCForL,
    dictionaries,
    // addComponent,
    rightButtons,
  },
  name: 'flUserCommunity',
  data () {
    return {
      // 点击数据的Id
      cholseId: '',
      defaultPropsLeft: {
        children: 'children',
        label: 'label',
      },
      //树形图选择
      treeNodeArray: [],
      left_loading: false,
      areaData: [],
      jurisdictionStatus: false,
      putUpdateUserAndMemberKey: 0,
      // 搜索框刷新组件
      searchKey: 0,
      // 角色Id
      roleIdData: null,
      // 编辑传回角色id
      roleIdDatass: null,
      // indexMethods:'',
      menuTrigger: '',
      //搜索
      searchContent: undefined,
      //后端传来的数据
      dataAttribute: [],
      //分页
      currentPage: 1, //当前页
      pagesize: 10, //每页条数
      pagetotal: 0, //总条数
      //查看的数据
      examineData: {},
      //查看的弹窗控制器
      DialogVisibleExamine: false,
      //表格中选中的数组
      multipleSelection: [],
      // 字典请求字段数据
      modelType: 'table',
      optionsZi: [],
      searchOptionTable: [],
      //数据模型
      dataModel: [
        // {
        // EN: "id",
        // CN: "序号",
        // value: "",
        // type: "input",
        // option: [],
        // typeFrom: "string",
        // Exp: "",
        // err: "",
        // result: true,
        // sign: true,
        // searchSign: false,
        // addSign: false,
        // tableSign: true,
        // examineSign: false,
        // examineDisabled: false,
        // modificationSign: false
        // },
        {
          EN: 'username',
          CN: '账户名称',
          value: '',
          type: 'input',
          option: [],
          typeFrom: 'string',
          Exp: '^[0-9A-Za-z]{4,14}$',
          err: '4-14个字符 数字和字母组成',
          result: true,
          sign: true,
          searchSign: true,
          addSign: true,
          tableSign: true,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        {
          EN: 'password',
          CN: '密码',
          value: '',
          type: 'input',
          option: [],
          typeFrom: 'string',
          Exp: '^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,20}$',
          err: '6-20个字符 数字和字符组成',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: false,
          examineDisabled: false,
          modificationSign: false,
        },
        {
          EN: 'name',
          CN: '用户名',
          value: '',
          type: 'input',
          option: [],
          typeFrom: 'string',
          Exp: '^.{2,20}$',
          err: '6-20个字符 数字和字符组成',
          result: true,
          sign: true,
          searchSign: true,
          addSign: true,
          tableSign: true,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        {
          EN: 'telPhone',
          CN: '手机号码',
          value: '',
          type: 'input',
          option: [],
          typeFrom: 'string',
          Exp: '^[1]([3-9])[0-9]{9}$',
          err: '请输入正确的手机号码！',
          result: true,
          sign: true,
          searchSign: true,
          addSign: true,
          tableSign: true,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        {
          EN: 'sysCompanyCode',
          CN: '租户',
          value: '',
          type: 'select',
          option: [],
          typeFrom: 'string',
          Exp: '',
          err: '',
          result: true,
          sign: true,
          searchSign: false,
          addSign: false,
          tableSign: true,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
          // dictTable:{
          //   table:'base_tenant_information',
          //   id:'sys_company_code',
          //   name:'name',
          //   associated:1
          // }
        },
        {
          EN: 'groupId',
          CN: '角  色',
          value: '',
          type: 'select',
          option: [],
          radio: [], //下面赋值
          Exp: '',
          err: '',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: false,
          examineDisabled: false,
          modificationSign: true,
          // dictTable:{
          //   table:'base_group',
          //   id:'id',
          //   name:'name',
          //   associated:'group_type%3D2'
          //   // associated:'group_type=2'
          // }
        },
        // {
        //   EN: "sex",
        //   CN: "性别",
        //   value: "",
        //   type: "input",
        //   option: [],
        //   typeFrom: "string",
        //   Exp: "",
        //   err: "",
        //   result: true,
        //   sign: true,
        //   searchSign: false,
        //   addSign: false,
        //   tableSign: false,
        //   examineSign: false,
        //   examineDisabled: false,
        //   modificationSign: false
        // },
        // {
        //   EN: "type",
        //   CN: "租户类型",
        //   value: "",
        //   type: "select",
        //   option: [
        //     {
        //       value: "1",
        //       label: "运维"
        //     },
        //     {
        //       value: "2",
        //       label: "租户管理员"
        //     }
        //   ],
        //   typeFrom: "string",
        //   Exp: "",
        //   err: "",
        //   result: true,
        //   sign: true,
        //   searchSign: false,
        //   addSign: false,
        //   tableSign: false,
        //   examineSign: true,
        //   examineDisabled: false,
        //   modificationSign: false,
        //   typeGroupCode:'we'
        // },
        {
          EN: 'status',
          CN: '状 态',
          value: '',
          type: 'select',
          option: [],
          typeFrom: 'string',
          Exp: '',
          err: '',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: true,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
          typeGroupCode: 'statusDct',
          // statusDct
        },
        {
          EN: 'description',
          CN: '描 述',
          value: '',
          type: 'input',
          option: [],
          typeFrom: 'string',
          Exp: '',
          err: '',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: true,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
          skipSign: true,
        },
        // {
        //   EN: "sysCompanyCode",
        //   CN: "租户管理员租户",
        //   value: "",
        //   type: "radio",
        //   option: [],
        //   radio: [], //下面赋值
        //   Exp: "",
        //   err: "",
        //   result: true,
        //   sign: true,
        //   searchSign: false,
        //   addSign: false,
        //   tableSign: false,
        //   examineSign: false,
        //   examineDisabled: false,
        //   modificationSign: false
        // },
      ],
      //角色
      ROLE: undefined,
      //用户角色
      useruData: [],
      // UserArr:undefined,
      // 改变的数据
      sysCompanyCodeRoles: '',
      // 租户信息
      getFindByTypeData: [],
      // 编辑中的角色默认值
      roleIdDataMod: '',
      id: 0,
      data: [],
      treeNodeArray: [],
      checkedId: '',
      nodeKey: '',
      anodes: [],
      deepNodeLabel: '',
    }
  },
  // searchContent.sysCompanyCode
  mounted () {
    this.getFindByType()
    // this.forData(this.currentPage, this.pagesize);
  },
  methods: {
    //
    checkClick (data, checked) {
      this.$refs.tree.setCheckedKeys([]) //清空所有选项
      if (this.id != data.id) {
        this.$refs.tree.setChecked(data.id, true) //如果不一样选中节点
        this.id = data.id //把节点选中的id赋值给id
        this.data = data //把选择节点的数据赋值需要的变量
      } else {
        this.$refs.tree.setCheckedKeys([]) //初始
        this.id = 0
        this.data = ''
      }
    },
    // checkChange(a, b, c) {  选中回调--
    checkChange (data, checked, node) {
      return
      if (checked === true) {
        this.checkedId = data.id
        this.$refs.tree.setCheckedKeys([data.id])
      } else {
        if (this.checkedId == data.id) {
          this.$refs.tree.setCheckedKeys([data.id])
        }
      }
      return
      console.log('+++-----', a, b, c, this.$refs.tree)
      let anode = this.$refs.tree.getNode(a)
      console.log(
        '+++',
        anode,
        '->>>',
        anode.label,
        anode.previousSibling && anode.previousSibling.label,
        anode.nextSibling && anode.nextSibling.label
      )
      this.getParentNode(anode.parent)
      this.getDeepChildrenNode(anode)
      this.getChildrenNodes(anode)
      if (anode.level == 1) {
        this.outParent(anode)
      }

      return
      !anode.checked ? this.findchildren(anode.parent) : ''
      // console.log(a,b,966);
      // this.treeNodeArray = b.checkedKeys
      // console.log('******************************')
      // console.log(this.treeNodeArray)
      // console.log(this.$refs.tree.getCheckedKeys())
      // console.log(this.$refs.tree.getHalfCheckedKeys())
      // let father=this.$refs.tree.getHalfCheckedKeys();
      // let child=this.$refs.tree.getCheckedKeys();
      // let newall=father.concat(child);
      // console.log(newall)
      // console.log('******************************')
      // this.treeNodeArray=JSON.parse(JSON.stringify(newall))
    },
    // 处理最外层父节点边界问题
    outParent (anode) {
      let { label, childNodes } = anode,
        { length } = childNodes
      if (childNodes && length) {
        for (let item of childNodes) {
          item.checked = label == item.label ? true : false
          if (item.childNodes && item.childNodes.length) this.outParent(item)
        }
      }
    },
    // 获取父节点下所有子节点-- 向下遍历
    getChildrenNodes (anode) {
      let { childNodes } = anode.parent,
        { length } = childNodes
      this.nodeKey = anode.label

      if (length && anode.level != 1) {
        // length < this.areaData.length
        console.log('老弟')
        this.deepNodeList(childNodes)
      }
    },
    // 深度遍历 -- 向下遍历
    deepNodeList (childNodes) {
      for (let item of childNodes) {
        if (this.nodeKey == item.label) {
          console.log('老妹')
          item.checked = true
          //continue
        } else {
          item.checked = false
        }
        if (item.childNodes && item.childNodes.length) {
          console.log('进来了吗')
          this.deepNodeList(item.childNodes)
        }
      }
    },
    // 获得同级节点-非最深子节点.
    getSiblingNodes (childNodes = []) {
      if (childNodes.length) {
        for (let item of childNodes) {
          if (this.deepNodeLabel == item.label) {
            item.checked = true
            // continue
          } else {
            item.checked = false
          }
          if (item.childNodes && item.childNodes.length) {
            console.log('1次')
            this.getSiblingNodes(item.childNodes)
          }
        }
      }
    },
    // 获取最深兄弟节点-- 向下遍历
    getDeepChildrenNode (anode) {
      // 二级节点下子节点单选；---向上遍历
      let { label } = anode,
        level
      this.deepNodeLabel = label

      if (anode.parent && anode.parent.level != 0) {
        console.log('几次-', anode.parent.level)
        level = anode.parent.level
        this.anodes = anode.parent
        this.getDeepChildrenNode(anode.parent)
      }
      if (level == 1) {
        console.log('几次前')
        this.getSiblingNodes(this.anodes.childNodes)
      }
      return
      // 二级字节点下，最深字节点独立选中;---向下遍历

      /* let { childNodes } = anode.parent,
        { length } = childNodes,
        { label } = anode
      if (!anode.childNodes.length && length && anode.level != 1) {
        // length < this.areaData.length
        console.log('\\\\\\\\\\', anode.parent.childNodes)

        for (let item of childNodes) {
          if (label == item.label) {
            item.checked = true
            continue
          } else {
            item.checked = false
          }
        }
      } */
    },
    // 兄弟节点
    getSiblingNode (anode) {
      if (!anode.nextSibling && !anode.previousSibling) {
        console.log('同级')
        if (anode.childNodes.length) {
          let itemNode
          for (let item of anode.childNodes) {
            item.checked = false
            itemNode = item
          }
          this.getSiblingNode(itemNode)
        }
      }
    },
    // 当前子节点的所有父节点，遍历到最外层一级节点
    getParentNode (node) {
      node.checked = false
      console.log('父级')
      if (node.parent && node.parent.label && node.level != 1) {
        this.getParentNode(node.parent)
      }
    },
    findchildren (current) {
      const fnode = this.$refs.tree.getNode(current)
      if (!fnode.isLeaf) {
        // fnode.indeterminate = false
        fnode.checked = false
      }
    },
    //树形图节点
    NodeClick (data, node, vm) {
      // this.middle_loading = true;
      // this.TreeSaveNode = node;
    },
    //树形图搜索框功能
    filterNode (value, data) {
      if (!value) return true
      return data.label.indexOf(value) !== -1
    },
    //重置按钮
    resetFun () {
      this.$refs.tree.setCheckedKeys([])
    },
    //全选
    clickAllFun () {
      // 父子不关联-深度遍历
      this.treeNodeArray = []
      if (this.areaData) this.getTreeNodes(this.areaData)
      return
      // 父子关联-只选择外层
      let ARR = []
      this.areaData.forEach((val) => {
        ARR.push(val.id)
      })
      this.treeNodeArray = ARR
    },
    getTreeNodes (treeNodes) {
      for (let item in treeNodes) {
        this.treeNodeArray.push(treeNodes[item].id)
        if (treeNodes[item].children) {
          this.getTreeNodes(treeNodes[item].children)
        }
      }
    },
    // 菜单保存
    async menuSave () {
      console.log(
        'this.$refs.tree.getCheckedKeys()--',
        this.$refs.tree.getCheckedKeys()
      )

      let father = this.$refs.tree.getHalfCheckedKeys()
      let child = this.$refs.tree.getCheckedKeys()
      console.log(child, 852)
      console.log(father, 851)

      let newall = father.concat(child)
      console.log(newall, 853)

      let userId = this.cholseId
      let arr = child
      if (!arr.length) {
        this.$message({
          message: '请选择小区',
          type: 'warning',
        })
        return
      }
      // let arr = newall
      console.log(userId, arr, '请求参数')
      // 发请求  保存 给提示
      // console.log('点击了保存');
      const res = await flUserCommunitySave(userId, arr['length'] ? arr : null)
      if (res.flag) {
        this.$message({
          message: res.message,
          type: 'success',
        })
      } else {
        this.$message({
          message: res.message,
          type: 'warning',
        })
      }
      console.log(res, 951)
    },
    //右侧弹窗关闭
    Conceal_201 () {
      this.jurisdictionStatus = false
    },
    async jurisdictionClick (row) {
      this.cholseId = row.id
      // 打开右侧页面  取反
      this.jurisdictionStatus = !this.jurisdictionStatus
      // 发送请求获取全部的tree 的数据
      this.treeNodeArray = []

      if (this.jurisdictionStatus) {
        // 请求全部的
        const res = await getTree()
        console.log(res, 999)
        this.areaData = res.data
        this.changeLabel(this.areaData)
        this.resetFun()
        // 传id  获取默认选中的数据
        // 请求默认选中的
        const moRes = await selectByUserId(row.id)

        this.treeNodeArray = moRes.data
        console.log(moRes, 666)
      }
    },
    // 转为label
    changeLabel (arr) {
      arr.forEach((item) => {
        for (var key in item) {
          if (key === 'name') {
            item['label'] = item[key]
            delete item[key]
          }
          if (key === 'children') {
            var arr1 = item[key]
            this.changeLabel(arr1)
          }
        }
      })
    },
    async resetPassWord () {
      let multipleSelection = this.multipleSelection
      if (multipleSelection.length === 0) {
        this.$message({
          message: '请选择要重置的账号',
          type: 'warning',
        })
      } else if (multipleSelection.length > 1) {
        this.$message({
          message: '不支持批量重置密码',
          type: 'warning',
        })
      } else {
        // 发请求   给提醒
        let id = this.multipleSelection[0].id
        console.log(this.multipleSelection[0], 9966)
        const res = await returnPass(id)
        if (res.flag) {
          this.$message({
            message: '密码重置成功,密码为123456',
            type: 'success',
          })
        } else {
          this.$message({
            message: '密码重置失败',
            type: 'warning',
          })
        }
      }
    },
    // 配置
    configuration (msg) {
      if (msg == '配置') {
        console.log(msg)
      }
    },
    // 重置
    emptySearch (msg) {
      if (msg == '重置') {
        let searchContent = this.searchContent
        console.log(this.searchContent, 855555)

        for (const key in this.searchContent) {
          if (this.searchContent.hasOwnProperty(key)) {
            this.searchContent[key] = ''
          }
        }
        console.log(this.dataModel, 966666)
        for (let i = 0; i < this.dataModel.length; i++) {
          this.dataModel[i].value = ''
        }
        console.log(this.searchContent, 'kankanjiguo')
        console.log(this.dataModel, 'dataModel')
        this.searchKey = this.searchKey + 1
        this.currentPage = 1
        console.log(this.currentPage, this.pagesize, this.searchContent, '参数')

        // this.forData(this.currentPage, this.pagesize);
        this.forData(this.currentPage, this.pagesize, this.searchContent)
      }
    },
    // 请求获取默认的角色
    // get
    // roleId(row){
    //   console.log(row,888);

    //   // const res = selectNameByuserId(row.sysCompanyCode)
    //   return row
    // },
    // addmodData(row){
    //   console.log(row);
    //   // 发送请求  拿到数据
    //   const res = selectNameByuserId(row.sysCompanyCode)
    //   console.log(res);

    //   // 给a添加数据
    //   // return
    //   return row
    // },
    // 编辑组件获取角色
    // async getSelectNameByuserId(id){
    //   console.log(id);

    //   const res = await selectNameByuserId(id)
    //   console.log(res.data);

    //   return res.data
    // },
    // 编辑传角色id
    sysRoleIdq (newId) {
      console.log(newId, '参数ID')
      this.roleIdDatass = newId
    },
    // 角色
    sysRoleId (newId) {
      console.log(newId, '参数ID')
      this.roleIdData = newId
    },
    // 获取租户信息
    async getFindByType () {
      // console.log('qian2222222222222222222222222222');
      const res = await findByType(0)
      console.log(res, 'hou2222222222222222222222222222222222')
      this.getFindByTypeData = res.data
      console.log(this.$refs.fication, 1111)

      console.log(this.getFindByTypeData, 99999666)
    },
    // 用于添加租户管理员时选择租户后之间传回选择租户的角色：
    // async getSelectByCodeAndTypeData(sysCompanyCode){
    //   console.log(sysCompanyCode,999999999);

    //   const res = await getSelectByCodeAndType(sysCompanyCode)
    //   console.log(res,'用于添加租户管理员时选择租户后之间传回选择租户的角色');

    //   const optionDatas = res.data
    //   this.sysCompanyCodeRoles = res.data
    // },
    // 重置
    // emptySearch(){
    //   this.searchContent = undefined;
    //   this.forData(this.currentPage, this.pagesize);
    // },
    handleSelectionChange (val) {
      this.multipleSelection = val
      console.log(this.multipleSelection)
    },
    //查看关闭弹窗
    examineDialog (dialogVisibleMod) {
      this.DialogVisibleExamine = false
    },
    async searchContentMod (data) {
      for (let i = 0; i < data.length; i++) {
        const element = data[i]
        console.log(element, 888888888888)

        const res = await selectNameByuserId(element.id)
        console.log(res, 77777)
        if (res.data) {
          element.groupId = res.data.id
        }
      }
      this.dataAttribute = data
      // console.log(data,'gaihaode ');
      // this.roleIdDataMod =
      // 整理groupId
      // selectNameByuserId()
    },
    //分页查询
    forData (page, size, content) {
      searchPageSize(page, size, content).then((response) => {
        // console.log(response);
        this.dataAttribute = response.data.list
        // 整理数据
        this.searchContentMod(this.dataAttribute)
        // console.log(this.dataAttribute,85263);

        this.pagetotal = response.data.total
      })
    },
    //分页
    handleSizeChange (val) {
      console.log('每页 ' + val + ' 条')
      this.pagesize = val
      this.forData(this.currentPage, val, this.searchContent)
    },
    handleCurrentChange (val) {
      console.log('当前页: ' + val)
      // 序号
      // this.indexMethod()
      this.forData(val, this.pagesize, this.searchContent)
      this.currentPage = val
    },
    //查询组件回调
    searchCallBack (newData) {
      let obj = {}
      for (let i = 0; i < newData.length; i++) {
        obj[newData[i].EN] =
          typeof newData[i].value == 'number'
            ? newData[i].value.toString().trim('')
            : newData[i].value.trim('')
      }
      // console.log(obj)
      this.searchContent = obj
    },
    //搜索
    sunS_F () {
      //console.log(this.searchContent); //用这组数据去ajax查询
      this.currentPage = 1
      this.forData(this.currentPage, this.pagesize, this.searchContent)
    },
    //增加
    toAdd (toAddData) {
      // console.log("toAddData");
      console.log(toAddData, 9999)

      let obj = {}
      for (let i = 0; i < toAddData.length; i++) {
        obj[toAddData[i].EN] = toAddData[i].value
      }
      // let roleIdData = obj.sysCompanyCode
      // console.log(obj,roleIdData,'????????????');
      // console.log(roleIdData,'roleIdData');
      let roleIdData = obj.groupId
      console.log(obj, roleIdData, '参数')

      postAddUserAndMember(obj, roleIdData)
        .then((response) => {
          this.forData(this.currentPage, this.pagesize, this.searchContent)
          this.$message({
            message: response.message,
            type: 'success',
          })
        })
        .catch(() => {
          this.$message.error('添加失败')
        })
    },
    //批量删除
    toDelete (toDeleteData) {
      console.log(toDeleteData)
      console.log(this.multipleSelection)
      let arr = []
      for (let i = 0; i < this.multipleSelection.length; i++) {
        arr.push(this.multipleSelection[i].id)
        this.$confirm('确认批量删除？')
          .then((_) => {
            deleteBaseTenantInformation(arr).then((response) => {
              this.forData(this.currentPage, this.pagesize, this.searchContent) //刷新列表
            })
            done()
          })
          .catch((_) => { })
      }
    },
    //单项删除
    deleteList (id) {
      console.log(id)
      let arrId = [id]
      this.$confirm('确认删除？')
        .then((_) => {
          deleteByuserId(arrId).then((response) => {
            this.forData(this.currentPage, this.pagesize, this.searchContent) //刷新列表
            this.$message({
              type: 'success',
              message: '已删除',
            })
          })
        })
        .catch((_) => {
          // this.$message({
          //   type:'warning',
          //   message:'已取消删除'
          // })
        })
    },
    //查看
    makeExaId (row) {
      let copyDialog = true
      this.DialogVisibleExamine = copyDialog
      this.examineData = row
    },
    //表格选中事件
    handleSelectionChange (val) {
      this.multipleSelection = val
      //传递删除的参数
      this.deleteDataList = val
    },
    //修改
    modifyData (value, MDData) {
      console.log(value, MDData, 'sss')
      if (value) {
        let id = MDData.id
        console.log(this.roleIdDatass, 'sssss9999')
        const roleIdDatass = this.roleIdDatass
        // var roleIdDatass = null
        // this.$nextTick(function(){
        //   roleIdDatass = this.roleIdDatass
        // })
        // const roleIdDatass = this.roleIdDatass
        // putUpdateUserAndMember
        console.log(roleIdDatass, id, MDData, 'chuancan?222')
        let groupId = MDData.groupId

        putUpdateUserAndMember(groupId, id, MDData)
          .then((Response) => {
            this.forData(this.currentPage, this.pagesize, this.searchContent)
            // this.$message({
            //   message: "修改成功!",
            //   type: "success"
            // });
          })
          .catch(() => {
            this.$message.error(
              '错误信息：api/admin/putUpdateUserAndMember/${id}！'
            )
          })
      }
    },
    modificationiButtonClick (newValue) {
      if (newValue == '点击编辑') {
        // this.putUpdateUserAndMemberKey = this.putUpdateUserAndMemberKey + 1
      }
    },
    // 字典组件回调
    dictionariesCallBack ([a = {}, b = {}]) {
      // 正常字典
      this.optionsZi = a
      // 跨表字典
      this.searchOptionTable = b
      console.log(a, b, 66688)
      // console.log(options, 111)
      // console.log(options,'huilaide');
      // this.optionsZi = options
      this.forData(this.currentPage, this.pagesize, this.searchContent)
      // }
    },
    // 序号
    indexMethod (index) {
      var currentPage = this.currentPage
      var pagesize = this.pagesize
      this.$nextTick(function () {
        currentPage = this.currentPage
        pagesize = this.pagesize
      })
      // console.log(currentPage,pagesize,'996');
      // console.log(currentPage*pagesize+index - 9);
      return currentPage * pagesize - pagesize + 1 + index
    },
  },
  computed: {
    // 字典计算属性
    optionDatas () {
      return function (arr, val, EN) {
        // 判断特殊
        if (EN == 'sysCompanyCode') {
          const getFindByTypeData = this.getFindByTypeData
          console.log(getFindByTypeData, '判断特殊')

          for (let i = 0; i < getFindByTypeData.length; i++) {
            const element = getFindByTypeData[i]
            console.log(element, '判断特殊element')
            if (getFindByTypeData[i].sysCompanyCode == val) {
              return getFindByTypeData[i].name
            }
          }
        }
        if (arr) {
          for (let i = 0; i < arr.length; i++) {
            if (arr[i].value == val) {
              // console.log(arr[i].label)
              return arr[i].label
            }
          }
        }
      }
    },
  },
  // watch:{
  //   searchContent(newValue){
  //     console.log(newValue.sysCompanyCode,'??');
  //     const sysCompanyCode = newValue.sysCompanyCode
  //     this.getSelectByCodeAndTypeData(sysCompanyCode)
  //   }
  // }
}
</script>
<style lang="scss" scoped>
.flUserCommunity {
  display: flex;
  .left {
    width: 100%;
  }
  .leftClick {
    width: 70%;
  }
  .right {
    width: 0;
    height: 80%;
    display: flex;
    background: #f0f4fa;
    overflow: auto;
  }
  .rightClick {
    height: 100vh;
    display: flex;
    background: #f0f4fa;
    overflow: auto;
    width: 30%;
    .left {
      flex: 1;
      border: 1px solid #ffffff;
      .zero {
      }
      .one {
        height: 35px;
        line-height: 35px;
        // border-top: 1px solid #efeeee;
        border-bottom: 1px solid #cccccc;
        .fontone {
          margin: 0px 10px;
          .icon {
            float: right;
            margin-right: 10px;
            cursor: pointer;
          }
        }
      }
      .btns {
        height: 45px;
        .childb {
          border: 1px solid #848484;
          background: #e7f5f9;
          font-size: 12px;
          color: #07799a;
          padding: 5px 5px;
          border-radius: 3px;
          margin: 4px 4px;
          :hover {
            background: #0b9ac3;
          }
        }
      }
      .treeFT {
        margin: 5px 5px;
      }
      .el-tree {
        background-color: #f0f4fa;
      }
    }
  }
}
</style>
